<template>
  <div class="app-container">
    <div class="zd3">
      <div class="zd3-title">
        <p>
          <span>选择仓库</span>
          <el-select
            v-model="searchData.cangku"
            :disabled="islook"
            placeholder="选择仓库"
            class="userselect"
          >
            <el-option
              v-for="item in cangkulist"
              :key="item.sid"
              :label="item.names"
              :value="item.names"
            ></el-option>
          </el-select>
        </p>
        <p>
          <span>入库日期</span>
          <el-date-picker v-model="searchData.yewutime" type="date" value-format="yyyy-MM-dd" class="userselect" placeholder="入库日期"></el-date-picker>
        </p>
        <el-button size="small" type="success" @click="getList">查询</el-button>
        <el-button size="small" @click="resetList">重置</el-button>
        <el-button size="small" type="primary" @click="addPermission" v-if="this.$store.state.user.userInfo[0].roleList[0].roleName !== 'dfZongjian'">新增</el-button>
      </div>
      <div class="zd3-btm" style="overflow:auto">
        <div class="designtable">
          <div class="designtable-title">
            <div class="title-left">
              <div class="titleleft-item" style="width: 50px">序号</div>
              <div class="titleleft-item">操作</div>
              <!-- <div class="titleleft-item">单据类型</div> -->
              <div class="titleleft-item">入库单号</div>
              <div class="titleleft-item">入库仓库</div>
              <div class="titleleft-item">入库日期</div>
              <div class="titleleft-item">供应商</div>
              <div class="titleleft-item">经办人</div>
              <div class="titleleft-item">经办日期</div>
              <div class="titleleft-item">入库备注</div>
            </div>
            <div class="title-right">
              <div class="titleright-top">入库明细</div>
              <div class="titleright-btm">
                <div class="titleright-btm-item">物品编码</div>
                <div class="titleright-btm-item">物品名称</div>
                <div class="titleright-btm-item">商品条码</div>
                <div class="titleright-btm-item">规格型号</div>
                <div class="titleright-btm-item">单位</div>
                <div class="titleright-btm-item">单价</div>
                <div class="titleright-btm-item">安全库存上限</div>
                <div class="titleright-btm-item">安全库存下限</div>
                <div class="titleright-btm-item">入库数量</div>
                <div class="titleright-btm-item">入库金额</div>
                <div class="titleright-btm-item">备注</div>
              </div>
            </div>
          </div>
          <div class="designtable-btm" v-for="(item,index) in tableData" :key="index">
            <div class="btm-left">
              <div class="btmleft-item" style="width: 50px">{{index+1}}</div>
              <div class="btmleft-item">
                <span @click="writeRow(item)">编辑</span>
                <span @click="deleteRow(item)">删除</span>
              </div>
              <!-- <div class="btmleft-item">
                <div class="orderStatus">
                  <p v-if="item.status == 0" class="yellow">未确认</p>
                  <p v-if="item.status == 1" class="blue">进行中</p>
                  <p v-if="item.status == 2" class="green">落实</p>
                </div>
              </div> -->
              <div class="btmleft-item">{{item.orderNumber}}</div>
              <div class="btmleft-item">{{item.cangku}}</div>
              <div class="btmleft-item">{{item.yewutime}}</div>
              <div class="btmleft-item">{{item.suppliers}}</div>
              <div class="btmleft-item">{{item.persons}}</div>
              <div class="btmleft-item">{{item.personTime}}</div>
              <div class="btmleft-item">{{item.remarks}}</div>
            </div>
            <div class="btm-right">
              <div class="btm-right-list" v-for="(item1,index1) in item.lists" :key="index1">
                <div class="btmright-list1">{{item1.bianma}}</div>
                <div class="btmright-list1">{{item1.names}}</div>
                <div class="btmright-list1">{{item1.propertyType}}</div>
                <div class="btmright-list1">{{item1.guige}}</div>
                <div class="btmright-list1">{{item1.danwei}}</div>
                <div class="btmright-list1">{{item1.unitPrice}}</div>
                <div class="btmright-list1">{{item1.anquanUp}}</div>
                <div class="btmright-list1">{{item1.anquanDowm}}</div>
                <div class="btmright-list1">{{item1.num}}</div>
                <div class="btmright-list1">{{item1.numJine}}</div>
                <div class="btmright-list1">{{item1.remarks}}</div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { selectHaocaiRuku, deleteHaocaiRuku,getSeting } from "@/api/caigou";
export default {
  data() {
    return {
      content: "",
      total: 1,
      page: 1,
      dialogVisible: false, //弹窗
      showHeader: true,
      loading: true,
      tableData: [
        {
          orderNumber: "551564122",
          remark: "清理说明",
          people: "清理人",
          time: "清理日期",
          status: "状态",
          detail: "资产明细",
        },
      ], //数据列表
      tempData: {}, //修改增加承载数据
      cangkulist: [],
      searchData: {
        ptypes: 2, //入库单
      }, //搜索承载数据
      time: "", //购入日期
      proData: [], //资产数据
      tempIndex: -1,
      ifydata: [],
      checkList: [],
    };
  },
  mounted() {
    this.getList();
    this.getSet()
  },
  methods: {
    /**
     * 跳转资产详情
     */
    goDetail(data) {
      console.log(data);
      this.$router.push({
        name: "Zichanmingxi",
        params: {
          options: JSON.stringify(data),
        },
      });
    },
    /**
     * 获取设置
     */
    getSet(){
      getSeting({}).then(res => {
        console.log('分类',res)
        this.cangkulist = res.data.filter(item => item.status === '3')
        console.log(this.gongying)
      })
    },
    getList() {
      selectHaocaiRuku(this.searchData).then((res) => {
        console.log(res);
        this.tableData = res.data.list;
        this.total = res.data.total;
        this.loading = false;
      });
    },
    designUpFile(item) {
      formData.append("file", item.file);
      importDaoshiCaigou(formData).then((res) => {
        console.log(res);
        this.$message({
          message: res.data.message,
          type: "success",
        });
      });
    },
    writeRow(item, index) {
      console.log(item);
      this.$router.push({
        name: "Writerukudan",
        params: {
          options: JSON.stringify(item),
        },
      });
    },
    look(item) {
      this.$router.push({
        name: "Writerukudan",
        params: {
          options: JSON.stringify(item),
          look: true,
        },
      });
    },
    deleteRow(item) {
      console.log("删除");
      this.$confirm('此操作将删除该条数据, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        deleteHaocaiRuku(item.lid).then(res => {
          console.log(res);
          this.$message({
            showClose: true,
            message: res.message,
            type: "success"
          });
          this.getList();
        });
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消删除'
        });          
      });
    },
    goPrev(page) {
      console.log(page);
      this.page--;
      this.getList();
    },
    goNext(page) {
      console.log(page);
      this.page++;
      this.getList();
    },
    goPage(page) {
      console.log(page);
      this.page = page;
      this.getList();
    },
    resetList() {
      this.searchData = {
        ptypes: 2
      };
    },
    addPermission() {
      this.$router.push({
        name: "Writerukudan",
      });
    },
  },
};
</script>

<style lang="scss" scoped>
// 自定义div表格
.designtable{
  width: 2570px;
  color: #666;
  &-title{
    position: relative;
    font-size: 14px;
    font-weight: 600;
    display: flex;
    height: auto;
    align-items: center;
    box-sizing: border-box;
    .caozuo{
      position: absolute;
      right: 0;
      top: 0;
      text-align: center;
      width: 150px;
      height: 60px;
      line-height: 60px;
      border-right:  1px solid #cccccc;
      border-bottom:  1px solid #ccc;
    }
    .title-left{
      display: flex;
      .titleleft-item{
        text-align: center;
        width: 150px;
        height: 60px;
        line-height: 60px;
        border-right:  1px solid #cccccc;
        border-bottom:  1px solid #ccc;
      }
    }
    .title-right{
      .titleright-top{
        text-align: center;
        border-bottom: 1px solid #ccc;
        box-sizing: border-box;
        height: 30px;
        line-height: 30px;
      }
      .titleright-btm{
        display: flex;
        .titleright-btm-item{
          width: 120px;
          height: 30px;
          text-align: center;
          border-right:  1px solid #ccc;
          border-bottom:  1px solid #ccc;
          line-height: 30px;
        }
      }
    }
  }
  &-btm{
    &:hover{
      background: #F0F0F0;
    }
    font-size: 14px;
    display: flex;
    .btm-left{
      display: flex;
      position: relative;
      .btmleft-item{
        width: 150px;
        padding: 8px 0;
        display: flex;
        align-items: center;
        justify-content: center;
        border-right:  1px solid #ccc;
        border-bottom:  1px solid #ccc;
        >span{
          cursor: pointer;
          color: #18a05e;
          padding: 0 8px;
          font-size: 12px;
        }
      }
    }
    .btm-right{
      .btm-right-list{
        display: flex;
        .btmright-list1{
          width: 120px;
          padding: 8px 0;
          text-align: center;
          border-right:  1px solid #ccc;
          border-bottom:  1px solid #ccc;
        }
      }
    }
  }
}
.orderStatus {
  display: flex;
  justify-content: center;
  > p {
    padding: 0px 5px;
    color: #fff;
    font-size: 12px;
    border-radius: 2px;
    margin: 0 0px 0 0;
  }
  .blue {
    background: #3a87ad;
  }
  .green {
    background: #18a05e;
  }
  .yellow {
    background: #ff7a0e;
  }
  .red {
    background: #c60000;
  }
  .zise {
    background: #c7ab10;
  }
}
.tables {
  box-shadow: 0 0 8px rgba(0, 0, 0, 0.1);
}
.title {
  display: flex;
  &-item {
    background: #eeeeee;
    font-size: 12px;
    font-weight: 700;
    color: #666;
    flex: 1;
    text-align: center;
  }
}
.lists {
  display: flex;
  padding: 5px 0;
  border-bottom: 1px solid #ccc;
  &:last-child {
    border-bottom: none;
  }
  &-item {
    flex: 1;
    font-size: 12px;
    color: #999;
    padding-right: 10px;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    > span {
      color: #18a05e;
    }
  }
}

.godetail {
  font-size: 14px;
  color: #18a05e;
  cursor: pointer;
}
/deep/.el-divider {
  background-color: #18a05e;
  position: relative;
}
.fanwei {
  padding-right: 20px;
}
/deep/.el-divider--horizontal {
  margin: 30px 0;
}
/deep/.el-divider__text {
  color: #18a05e;
  font-size: 16px;
}
/deep/.el-button--primary {
  color: #fff;
  background-color: #18a05e !important;
  border-color: #18a05e !important;
}
/deep/.el-button--primary:hover,
.el-button--primary:focus {
  background: #18a05e !important;
  border-color: #18a05e !important;
  color: #fff !important;
}
/deep/.el-button:hover,
.el-button:focus {
  color: #18a05e;
  background-color: transparent;
}
/deep/.el-button--primary {
  color: #fff;
  background-color: #18a05e;
  border-color: #18a05e;
}
/deep/.el-button--text {
  color: #00c666 !important;
}
.upload-demo {
  margin-left: 10px;
}
.app-container {
  padding: 10px;
}
.ellisp {
  width: 100%;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  overflow: hidden;
  text-align: left;
}
.rolestip {
  width: 100%;
  display: flex;
  justify-content: center;
}
.inps {
  width: 100%;
  height: 32px;
  line-height: 32px;
  padding-left: 10px;
  background: none;
  border: none;
  color: #333;
}
.inps-active {
  width: 100%;
  height: 32px;
  line-height: 32px;
  padding-left: 10px;
  // background:#ccc;
  border: none;
  color: #333;
}
.s-img {
  width: 80px;
  height: 80px;
}
.zd3-title {
  height: 70px;
  display: flex;
  align-items: center;
  padding: 0 20px;
  position: relative;
  background: #ffffff;
  border-radius: 8px;
  border: 1px solid rgba(0, 0, 0, 0.1);

  > p {
    font-size: 14px;
    color: #333;
    margin-right: 20px;

    > span {
      padding-right: 20px;
    }
    /deep/.el-input__inner {
      width: 150px;
      background: none;
      height: 32px;
      color: #333;
      border: 1px solid rgba(0, 0, 0, 0.1);
      padding: 0 25px;
    }
    /deep/.el-date-editor.el-input, .el-date-editor.el-input__inner {
      width: 150px !important;
    }
    /deep/.el-input__icon {
      line-height: 32px;
    }

    > input {
      width: 150px;
      height: 32px;
      // background: #ccc;
      border-radius: 3px;
      border: 1px solid #ccc;
      padding-left: 10px;
      color: #333;
    }
  }

  > h3 {
    // width: 64px;
    height: 32px;
    background: #18a05e;
    border-radius: 3px;
    margin: 0 30px 0 0;
    padding: 0 15px;
    color: #fff;
    font-size: 14px;
    line-height: 32px;
    font-weight: 100;
    text-align: center;
    cursor: pointer;
  }

  > h4 {
    padding: 0 15px;
    height: 32px;
    border-radius: 3px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    color: #333;
    font-size: 14px;
    line-height: 32px;
    font-weight: 100;
    text-align: center;
    cursor: pointer;
  }
}
/deep/.el-pagination.is-background .el-pager li:not(.disabled).active {
  background-color: #18a05e;
  color: #fff;
}
.zd3-btm /deep/.btn-prev:after {
  content: "上一页";
}
.zd3-btm /deep/.btn-next:before {
  content: "下一页";
}
.zd3-btm /deep/.btn-prev,
.zd3-btm /deep/.btn-next {
  width: 65px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.zd3-btm {
  background: rgba(255, 255, 255, 1);
  border-radius: 8px;
  border: 1px solid rgba(0, 0, 0, 0.1);
  margin-top: 10px;
  overflow: hidden;
  &-title {
    display: flex;
    align-items: center;
    height: 70px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    background: #ffffff;
    > p {
      text-align: center;
      font-size: 16px;
      color: #333;
    }
  }
  .el-pagination {
    white-space: nowrap;
    padding: 15px 5px;
    color: #303133;
    font-weight: bold;
  }
  .addDate {
    margin: 20px 32px 10px 32px;
    height: 32px;
    border-radius: 3px;
    text-align: center;
    line-height: 32px;
    font-size: 14px;
    color: #333;
    cursor: pointer;
    border: 1px dashed rgba(0, 0, 0, 0.25);
  }
  .el-button--text {
    margin: 0 10px;
  }
}
.dialog {
  height: 350px;
  overflow-y: auto;
}
/deep/.el-dialog__body {
  padding: 10px 20px;
}
.change1 {
  display: flex;
  padding: 20px 20px 20px 0;
  flex-wrap: wrap;
  > p {
    width: 100%;
    font-size: 14px;
    display: flex;
    margin: 10px 0;
    align-items: center;
    color: #999;
    > span {
      display: block;
      width: 120px;
      text-align: right;
      padding-right: 15px;
      color: #18a05e;
    }
  }
}
.change {
  display: flex;
  padding-right: 20px;
  flex-wrap: wrap;
  .fuxuan {
    display: flex;
    justify-content: center;
    margin: 10px auto;
  }
  > p {
    width: 50%;
    font-size: 14px;
    display: flex;
    margin: 10px 0;
    align-items: center;
    color: #333;
    /deep/.el-input__inner {
      width: inherit;
      background: none;
      height: 32px;
      // line-height: 32px;
      color: #333;
      border: 1px solid rgba(0, 0, 0, 0.1);
      padding: 0 25px;
    }
    /deep/.el-input__icon {
      line-height: 32px;
    }
    .userselect {
      // max-width: 250px;
      flex: 1;
    }

    > span {
      display: block;
      width: 120px;
      text-align: right;
      padding-right: 15px;
    }
    > input {
      width: inherit;
      flex: 1;
      height: 32px;
      border-radius: 3px;
      border: 1px solid rgba(0, 0, 0, 0.1);
      padding-left: 10px;
      color: #333;
    }
  }
}
</style>
